Skip to content

feat: redesign BacktestReport — unified HTML dashboard#420

Merged
MDUYN merged 6 commits into
devfrom
feature/redesign-backtest-report
Apr 11, 2026
Merged

feat: redesign BacktestReport — unified HTML dashboard#420
MDUYN merged 6 commits into
devfrom
feature/redesign-backtest-report

Conversation

@MDUYN
Copy link
Copy Markdown
Collaborator

@MDUYN MDUYN commented Apr 6, 2026

Redesign BacktestReport — Unified Single & Multi-Strategy HTML Dashboard

Closes #401

What changed

Replaced the old Plotly-based backtest report with a self-contained HTML dashboard that works for both single-strategy and multi-strategy backtests.

Key features

  • Zero external dependencies — canvas-based charts, all CSS/JS inlined in output HTML
  • Jinja2 template — separate CSS, JS, and HTML template files for maintainability
  • Multi-strategy comparison — ranking table, overlay equity curves, metric bar charts (CAGR, Sharpe, Max DD, Win Rate)
  • Strategy selection — click strategies to filter equity curves and comparison charts
  • Ranking table pagination — Top 5/10/20/50/All selector with Prev/Next navigation
  • Backtest window analysis — dedicated Windows page with per-window metrics table
  • Theme support — light theme default, system dark mode detection (prefers-color-scheme), manual toggle
  • Overview KPIs — Strategies, Windows, Best CAGR, Best Sharpe, Best Sortino, Best Calmar, Best Win Rate, Lowest Max DD

Bug fixes

  • _is_backtest() now checks for algorithm_id.json + runs/ directory (matches actual saved format)
  • Fixed tuple unpacking for all time-series data (equity_curve, drawdown_series, rolling_sharpe_ratio, monthly_returns, yearly_returns)

Files changed

File Change
app/reporting/backtest_report.py Refactored to Jinja2 with data transformation methods
app/reporting/templates/dashboard.css New — extracted stylesheet
app/reporting/templates/dashboard.js New — all client-side interactivity
app/reporting/templates/dashboard_template.html.j2 New — Jinja2 HTML template
tests/app/reporting/test_backtest_report_html.py New — 23 unit tests
examples/open.py New — example script for opening reports
README.md Added "Opening Backtest Reports" section
docusaurus/docs/Getting Started/backtest-reports.md New documentation page
docusaurus/docs/Getting Started/backtesting.md Updated with link to report docs
docusaurus/sidebars.js Added backtest-reports entry

Testing

  • 23 unit tests covering HTML generation, KPI extraction, theme, pagination, and edge cases
  • Manual testing with examples/open.py confirmed dashboard renders correctly

MDUYN added 6 commits April 6, 2026 13:12
…dashboard

- Replace old Plotly-based report with self-contained HTML dashboard
- Jinja2 template with canvas-based charts, zero external dependencies
- Separate CSS/JS/HTML template files for maintainability
- Multi-strategy comparison: ranking table, equity curves, metric bars
- Strategy selection filters equity curves and metric comparison charts
- Pagination with Top 5/10/20/50/All for ranking table
- Backtest window dropdown to view per-window metrics
- Windows page with dedicated backtest window analysis table
- System theme detection (prefers-color-scheme) with manual toggle
- Overview KPIs: CAGR, Sharpe, Sortino, Calmar, Win Rate, Max DD
- Fix _is_backtest() to match actual saved format
- Fix tuple unpacking for all time-series data
- Add example script and documentation
- 23 unit tests for HTML report generation

Closes #401
- Add recalculate_backtests() to recompute all per-run and summary
  metrics from raw portfolio snapshots and trades
- Redesign compare page: Key Metrics, Trading Activity, Return Scenarios
  ranking tables (overview style)
- Merge Monthly Returns + Monthly Return Distribution into single
  component with Returns/Growth x Rows/Heatmap toggles + year filter
- Add trades_per_month/week metrics to BacktestMetrics and summary
- Add Recovery Factor and Volatility to Key Metrics table
- Update backtest-reports.md docs with recalculate_backtests API and
  updated dashboard feature descriptions
- Add test_recalculate_backtests.py with idempotency and consistency tests
- Wire recalculate_backtests into examples/open.py
- Restructure README around create → backtest → compare → deploy loop
- Add detailed Backtest Report Dashboard section (overview + compare pages)
- Shorten strategy example from ~200 lines to ~30 lines
- Move sponsor section into header with styled layout
- Clean up features table and remove emoji clutter
- Fix test tuple order in test_backtest_report_html.py (value, date)
…improvements

- Add parameters field to Backtest dataclass (save/open/merge)
- Add set_parameters()/get_parameters() to TradingStrategy
- Wire parameters through backtest service and report builder
- Add Parameters Comparison table on compare page
- Add Strategy Parameters card on per-strategy pages
- Add Parameters tab in strategy selection modal with chip/range filters
- Fix buildCompareParameters to use selectedForCompare
- Auto-apply param filters on modal close
- Dashboard: metrics fixes, README updates
@MDUYN MDUYN marked this pull request as ready for review April 11, 2026 13:19
@MDUYN MDUYN merged commit 1c3d0ad into dev Apr 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant